package com.ruoyi.company.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.company.domain.MonthlyCardMsg;
import com.ruoyi.company.service.MonthlyCardMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/buiness/monthlyCardMsg")
public class MonthlyCardMsgController extends BaseController {

    @Autowired
    private MonthlyCardMsgService monthlyCardMsgService;

    @GetMapping("/page")
    public TableDataInfo page(MonthlyCardMsg monthlyCardMsg) {
        startPage();
        List<MonthlyCardMsg> list = monthlyCardMsgService.list(monthlyCardMsg);
        return getDataTable(list);
    }

    @GetMapping("/finish/{id}")
    public AjaxResult finish(@PathVariable("id") Long id) {
        Integer finish = monthlyCardMsgService.finish(id);
        return finish == 1 ? AjaxResult.success() : AjaxResult.error();
    }

    @PostMapping("/insertMonthlyCardMsg")
    public AjaxResult insertMonthlyCardMsg(@RequestBody MonthlyCardMsg monthlyCardMsg) {
        return AjaxResult.success(monthlyCardMsgService.insertMonthlyCardMsg(monthlyCardMsg));
    }
    @PostMapping("/updateMonthlyCardMsg")
    public AjaxResult updateMonthlyCardMsg(@RequestBody MonthlyCardMsg monthlyCardMsg) {
        return AjaxResult.success(monthlyCardMsgService.updateMonthlyCardMsg(monthlyCardMsg));
    }
}
